<%@ page contentType="text/html;charset=UTF-8" %> 
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
   
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    
    <script type="text/javascript">
//     $(document).ready(function(){
//     if ($("#id").val()!=null&&$("#id").val()!=0) {
// 		$("#itemCode").attr("disabled","disabled");
// 		}
// 	}); 
	    //保存方法
	    var saveDict={
	         t:null,
	         save:function(t){
	              $(t).attr("disabled",true);
	              this.t=t;
	              // 表单验证
	              $("#inputForm").validate({
	                   // 重名验证
	                   rules: {
	                    itemCode: {remote: "${ctx}/database/message/checkName?oldItemValue=${dict.oldItemValue}"}
	                   },
	                   messages: {
	                    //数据值以存在
	                    itemCode: {remote: '<spring:message code="data_code_have_exits"/>'}
	                   },
	                   fail: function(element,e) {  
	                        $(saveDict.t).attr("disabled",false);
	                   },
	                   submitHandler: function() {
	                	// 格式化，去除逗号
	                         formUnFormat($("#inputForm"));
	                	    var params = $("#inputForm").serialize();
	                	    var itemCode = $("#itemCode").val();
	            	    	var itemNameCn = $("#itemNameCn").val();
	            	    	var itemNameEn = $("#itemNameEn").val();
	            	    	var itemNameJp = $("#itemNameJp").val();
	            	    	var remarks = $("#remarks").val();
	            	    	var oldItemValue = $("#oldItemValue").val();
	            	    	var id = $("#id").val();
	            	    	
	                	    // 调用后台删除方法
	            	        $.post("${ctx}/database/message/save?itemCode="+$("#itemCode").val() +"&itemNameCn=" + itemNameCn +"&itemNameEn=" + itemNameEn
	            	        		+"&itemNameJp=" + itemNameJp +"&remarks=" + remarks+"&id=" + id +"&oldItemValue="+oldItemValue, "",function(result) {
	            	             // 提示信息
	            	             tipParent(result.message);
	            	             // 返回状态
	            	            if(result.statusCode==STATUSCODEOK){
	            	            	// 刷新页面
	                                window.parent.frames[0].searchListForm();
	            	                 // 关闭页面
	            	                closeWin(); 
	            	             }
	            	        },'json');
	                   }
	              });
	              // 提交表单
	              $("#inputForm").submit(); 
	         } 
	    }
	    
	 
	    //删除方法
	    function deleteCurrentRow(t){
	    	if (confirm("确定删除吗？")) {
	    		//获取 iframe 数量 
            	var frLength = window.parent.frames.length;
            	//父画面下标 
            	var parentIndex = frLength-2;
	          // 调用后台删除方法
	        $.post("${ctx}/database/message/delete?id="+t+"&&oldItemValue=${dict.oldItemValue}",'',function(result){
	             // 提示信息
	             tipParent(result.message);
	             // 返回状态
	            if(result.statusCode==STATUSCODEOK){
	                 // 刷新页面
	                window.parent.frames[parentIndex].location.reload();
	                 
	             
	             }
	        },'json');
			}
	   }
	  
	    

	    //编辑方法
	    function addBankCheck(t){
	          // 调用后台编辑方法
	       popup("716px","407px","${ctx}/database/message/formTwo?id="+t+"&&oldItemValue=${dict.oldItemValue}");
	            
	   }
	    
	    //编辑方法
	    function addBankChecktwo(t){
	          // 调用后台编辑方法
	          var itemCode = $("#itemCode").val(); 
	       popup("716px","407px","${ctx}/database/message/formThree?itemCode="+itemCode);
	            
	        
	   }
	    
	function newSearch(){
		var id='${dict.id}';
		$.post("${ctx}/database/message/newSearch?id="+id,'',function(result){
            // 返回状态
          $("#perantTable").html($(callBackHtml(result)).find("#perantTable").html());
            
       },'html');
	
	}
	
    // 删除子项目
    function deleteSub(delIndex){
        // 调用后台删除子项方法
        $.post("${ctx}/database/message/deleteSub?delIndex=" + delIndex, "", function(result) {
            // 回调函数赋值
            var h = $(callBackHtml(result)).find("#itemSub").html();
            $('#itemSub').html(h);
        }, 'html');
    }

    // 新建子项
    function createSubItem(delIndex) {
    
           
        // 项目值不能为空
        if ($('#itemCode').val() != "") {

        	   popup('800px','519px','${ctx}/database/message/formSub?itemCode=' + $('#itemCode').val()+"&delIndex="+delIndex);

        } else {

             // 请输入合法项目值！
             layer.msg('<spring:message code="data_code_cannot_empty"/>', {time:1000});

        }
     
    }

    
    
    
    
    //选择添加子项目
    function addItemValue(){
        // 调用后台查询子项list
        $.post("${ctx}/database/message/searchSubList", "", function(result) {
            // 回调函数赋值
            var h = $(callBackHtml(result)).find("#itemSub").html();
            $('#itemSub').html(h);
        }, 'html');
    }
    </script>
    
</head>
<body>   
<form id="inputForm" method="post">
<!-- 创建编辑头部 -->

<div id="createHead" class="layerHeader clearfix">
<p class="headerTitle"><spring:message code="dict_modifyDict"/></p>
    <div class="headerButton clearfix">
            <!-- 编辑 -->
	        <shiro:hasPermission name="database:message:edit">
            <!-- 保存 -->
            <button type="button" onclick="saveDict.save(0,this)"><spring:message code="role_save"/></button>
            </shiro:hasPermission>
        <!-- 取消 -->
        <button type="button" onclick="closeWin()"><spring:message code="company_edit_cancle"/></button>
    </div>
</div>
<!-- 入力框 -->

<div id="showHtml" class="tabBoxSm" >
    <div class="tabSm smOrderBox">
        <div class="clearfix">
        <input type="hidden" id="id" name="id" value="${dict.id }"/>
         <input type="hidden" id="oldItemValue" name="oldItemValue" value="${dict.oldItemValue }"/>
    	<input type="hidden" id="createDate" name="createDate" value="${fns:getDate('yyyy-MM-dd HH:mm')}">
    	<input type="hidden" id="createID" name="createID" value="${fns:getUser()}">
    	<input type="hidden" id="companyID" name="companyID" value="${companyList.companyID}">
        <input type="hidden" id="editFlag" name="editFlag" value="${companyList.editFlag}">
        	<div class="">
        	<div class="col-50 items clearfix">
        	</div>
                <!--  数据代码  -->
              <div class="col-50 items clearfix haveToBox">
	        		<!-- 数据代码 -->   
	                <p class="tit"><spring:message code="dict_itemCode" /></p>
					<input id="itemCode" name="itemCode" value="${dictListFind[0].itemCode}" style="margin-left: 30px"  data-rule-required="true" data-msg-required="<spring:message code="data_code_cannot_empty" />">
                    <p class="haveTo">*</p>
	            </div>  
            </div>
            <div class="">
        	   <!--  中文全称： -->
            	<div class="col-50 items clearfix haveToBox">
                	<p class="tit"><spring:message code="fitproperty_Cn_show"/></p>
                    <input id="itemNameCn" name="itemNameCn" style="margin-left: 30px" value="${dictListFind[0].itemNameCn}" >
                </div>
                 <!--  英文全称-->
                <div class="col-50 items clearfix haveToBox">
                	<p class="tit"><spring:message code="fitproperty_En"/></p>
                    <input id="itemNameEn" name="itemNameEn" style="margin-left: 30px" value="${dictListFind[0].itemNameEn}" >
                </div>
            </div>
            <div class="">
               <!--  日文全称 -->
                <div class="col-50 items clearfix haveToBox">
                	<p class="tit"><spring:message code="fitproperty_Jp_show"/></p>
                    <input id="itemNameJp" name="itemNameJp" style="margin-left: 30px" maxlength="50" value="${dictListFind[0].itemNameJp}" >
                </div>
                <!--  描述-->
                <div class="col-50 items clearfix haveToBox">
                	<p class="tit" ><spring:message code="describe_remark"/></p>
         			<input id ="remarks" type="text"  style="margin-left: 30px ; with:150px;height:30px" value="<c:forEach items="${dictList}" var="dict" varStatus="status" begin="0" end="2" step="1"><c:if test="${status.index!=0 }">/</c:if>${dictList[status.index].itemNameCn}</c:forEach><c:if test="${dictList.size()>3 }">......</c:if>"/>
                </div>
            </div>
        </div> 
	</div>
	<!-- 银行账户信息 -->
    <div class="" id="itemSub">
    	<div class="tableArea">
			<div class="">
				<div style="float: left;margin-left: 10px">
				
				<p class="tit"><spring:message code="fitproperty_sub_show_aaa"/><button type="button" onclick="createSubItem(-1)"><spring:message code="dict_chooseAdd"/></button></p>
				
				</div>
				<div style="float: right;"> 
				</div>
			</div>
			
        	<div class="tableScroll tableScrollSm" style="padding-top: 0px;margin-left: 50px" >
        	 <div style = "overflow: auto; position: relative;background-color:#ddd;">
        		<table cellpadding="0" class="" style="border: none">
                    <tr>
                        <th class="table-gszhkhmc" style="border: none"><spring:message code="dict_delete"/></th>
                        <th class="table-gszhkhwd" style="border: none"><spring:message code="shujudaima"/></th>
                        <th class="table-gszhkhmc" style="border: none"><spring:message code="shujuzhongwen"/></th>
                        <th class="table-gszhkhzh" style="border: none"><spring:message code="shujuyingwen"/></th>
                        <th class="table-gszhkhwd" style="border: none"><spring:message code="shujuriwen"/></th>
                        <th class="table-gszhkhmc" style="border: none"><spring:message code="zhuangtai"/></th>
                    </tr>
                    </table>
                      </div>
                    <div style = "overflow: auto; position: relative;background-color:#fff;border:1px solid #B7B9B8;height:252px;">
                    <table cellpadding="0" class="" name ="perantTable" id ="perantTable" >
         		<c:forEach items="${dictList}" var="dict" varStatus="status">
                    <tbody >
                    <tr>
                        <td style="border: none;border-bottom:1px solid #B7B9B8; border-right:1px solid #B7B9B8" class="table-gszhkhmc"><img src="/ls-qc/static/images/btn-bj.png" onclick="createSubItem(${status.index})" height="30" width="30">&nbsp;&nbsp;
                        <img src="/ls-qc/static/images/btn-sc.png" height="30" width="30"  onclick="deleteSub(${status.index})"></td>
                        <td style="border: none;border-bottom:1px solid #B7B9B8; border-right:1px solid #B7B9B8" class="table-gszhkhwd">${dict.itemValue }</td>
                        <td style="border: none;border-bottom:1px solid #B7B9B8; border-right:1px solid #B7B9B8" class="table-gszhkhmc">${dict.itemNameCn }</td>
                        <td style="border: none;border-bottom:1px solid #B7B9B8; border-right:1px solid #B7B9B8" class="table-gszhkhzh">${dict.itemNameEn }</td>
                        <td style="border: none;border-bottom:1px solid #B7B9B8; border-right:1px solid #B7B9B8" class="table-gszhkhwd">${dict.itemNameJp }</td>
                        <c:if test="${dict.enableFlag == 1}">
                        <td style="border: none;border-bottom:1px solid #B7B9B8;" class="table-gszhkhmc">启用</td>
                        </c:if>   
                         <c:if test="${dict.enableFlag == 0}">
                        <td style="border: none;border-bottom:1px solid #B7B9B8;" class="table-gszhkhmc">停用</td>
                        </c:if>    
                        
                    </tr>
                	</tbody>
                </c:forEach>
                </table>
                <div id="hiddenHtml"></div>
             </div>
          </div>
        </div>
    </div>
</div>

</form>
<script>
</script>
</body>
</html>
